//
//  YuErViewController.m
//  Cat
//
//  Created by lushitong on 2019/1/25.
//  Copyright © 2019年 lushitong. All rights reserved.
//

#import "YuErViewController.h"
#import "BalanceTableView.h"
#import "WSDatePickerView.h"

@interface YuErViewController ()

@property (nonatomic, strong) BalanceTableView *balanceTableView;

@end

@implementation YuErViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.topTitleView setDetailDic:@{Nav_Title:@"余额明细",Nav_RightTxt:@"筛选"}.mutableCopy];
	[self.view addSubview:self.balanceTableView];
}

+ (NSArray *)getCurrentYearAndMonth:(NSInteger)afterYear {
	// 获取代表公历的NSCalendar对象
	NSCalendar *gregorian = [[NSCalendar alloc]
							 initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
	// 获取当前日期
	NSDate* dt = [NSDate date];
	// 定义一个时间字段的旗标，指定将会获取指定年、月、日、时、分、秒的信息
	unsigned unitFlags = NSCalendarUnitYear |
	NSCalendarUnitMonth |  NSCalendarUnitDay |
	NSCalendarUnitHour |  NSCalendarUnitMinute |
	NSCalendarUnitSecond | NSCalendarUnitWeekday;
	// 获取不同时间字段的信息
	NSDateComponents* comp = [gregorian components: unitFlags
										  fromDate:dt];
	return @[@(comp.year + afterYear),@(comp.month)];
}

- (void)p_topRightBtnClick {
	
	WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYearMonth scrollToDate:nil CompleteBlock:^(NSDate *selectDate) {
		NSString *dateString = [selectDate stringWithFormat:@"yyyy-MM"];
		NSArray *array = [dateString componentsSeparatedByString:@"-"];
		NSLog(@"%@",array);
	}];
	
	datepicker.dateLabelColor = [UIColor colorWithHexString:@"000000"];//年-月-日-时-分 颜色
	datepicker.datePickerColor = [UIColor colorWithHexString:@"000000"];//滚轮日期颜色
	datepicker.doneButtonColor = [UIColor colorWithHexString:@"#F7AC01"];//确定按钮的颜色
	datepicker.isForeign = NO;
	datepicker.maxLimitDate = [NSDate date:nil WithFormat:@"yyyy-MM-dd HH:mm"];
	datepicker.minLimitDate = [NSDate date:nil WithFormat:@"yyyy-MM-dd HH:mm"];
	[datepicker show];
}

- (BalanceTableView *)balanceTableView {
	if (!_balanceTableView) {
		_balanceTableView  =[[BalanceTableView alloc] initWithFrame:CGRectMake(0.0, self.topTitleView.bottom, ScreenWidth, ScreenHeight - self.topTitleView.height - kQKFitModule(1.0)) sections:1];
	}
	return _balanceTableView;
}

@end
